<template>
    <div class="main">
        <van-divider><h2>注册</h2></van-divider>

    <van-form @submit="onSubmit">
  <van-field
    v-model="phone"
    label="手机号："
    placeholder="手机号"
    v-model.number="phone"
    :rules="[{ required: true, message: '请填写手机号' },{pattern:/^1[356789]\d{9}$/, message: '手机号格式错误' }]"
  />
  <van-field
    v-model="password"
    type="password"
    label="密码"
    placeholder="请输入密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">立即注册</van-button>
  </div>
</van-form>
    <a href="#" @click.prevent="jump()">已有帐户，去登录</a>
    </div>
</template>
<script>
import url from "../tools/url"

import { Toast } from 'mint-ui';
export default {
    name:"register",
    data() {
        return {
            phone:"",
            password:""
        }
    },
    methods: {
        jump(){
            this.$router.push("/login").catch(e=>{})
        },
       onSubmit(){
           var str=`phone=${this.phone}&password=${this.password}`
           this.axios.post(url.LOGINOUT,str).then((pro)=>{
               console.log(pro);
               if(pro.data.code==200){
                   this.$router.push("/login").catch(e=>{});
               }
               else{
                    Toast(pro.data.message);
               }
           })
       }
    },
    mounted() {
        
    },
    destroyed() {
        
    },
    computed: {

    },
}
</script>
<style scoped>
.main{
    text-align: center;
}

a{
     text-decoration:none;
     color: rgb(113, 107, 107);
}
</style>